<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>股票异动预警详情</title>
    <meta name="description" th:content="详情">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 400px;
            margin: 0 auto;
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            animation: slideUp 0.3s ease-out;
        }

        @keyframes slideUp {
            from {
                transform: translateY(20px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px 20px;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .header::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: shimmer 3s infinite;
        }

        @keyframes shimmer {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .header h1 {
            font-size: 22px;
            font-weight: 600;
            position: relative;
            z-index: 1;
        }

        .alert-icon {
            width: 60px;
            height: 60px;
            margin: 0 auto 15px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            z-index: 1;
        }

        .alert-icon::before {
            content: '⚠️';
            font-size: 30px;
        }

        .content {
            padding: 30px 25px;
        }

        .stock-info {
            display: flex;
            align-items: center;
            margin-bottom: 25px;
            padding: 20px;
            background: #f8f9ff;
            border-radius: 12px;
            border-left: 4px solid #667eea;
        }

        .stock-code {
            font-size: 24px;
            font-weight: bold;
            color: #333;
            margin-right: 15px;
        }

        .stock-name {
            font-size: 18px;
            color: #666;
            font-weight: 500;
        }

        .info-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-bottom: 25px;
        }

        .info-item {
            background: #fafbfc;
            padding: 20px;
            border-radius: 12px;
            border: 1px solid #e1e5e9;
            transition: all 0.3s ease;
        }

        .info-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .info-label {
            font-size: 13px;
            color: #8b949e;
            margin-bottom: 8px;
            font-weight: 500;
        }

        .info-value {
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }

        .price-up {
            color: #ff4757;
        }

        .price-down {
            color: #2ed573;
        }

        .alert-time {
            text-align: center;
            padding: 20px;
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            border-radius: 12px;
            margin-bottom: 25px;
        }

        .alert-time-label {
            font-size: 14px;
            opacity: 0.9;
            margin-bottom: 5px;
        }

        .alert-time-value {
            font-size: 16px;
            font-weight: 600;
        }

        .risk-warning {
            background: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
            padding: 20px;
            border-radius: 12px;
            text-align: center;
            font-size: 15px;
            font-weight: 500;
            line-height: 1.6;
            position: relative;
            overflow: hidden;
        }

        .risk-warning::before {
            content: '⚡';
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 20px;
            opacity: 0.5;
        }

        .loading {
            text-align: center;
            padding: 40px;
            color: #666;
        }

        .loading::after {
            content: '';
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-left: 10px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .error {
            text-align: center;
            padding: 40px;
            color: #e74c3c;
        }

        .error-message {
            background: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }

        .analysis-report {
            margin-bottom: 25px;
        }

        .report-btn {
            display: flex;
            align-items: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
        }

        .report-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
        }

        .report-icon {
            font-size: 24px;
            margin-right: 12px;
        }

        .report-text {
            flex: 1;
            font-size: 16px;
            font-weight: 600;
        }

        .report-arrow {
            font-size: 18px;
            transition: transform 0.3s ease;
        }

        .report-btn:hover .report-arrow {
            transform: translateX(4px);
        }

        .no-report {
            text-align: center;
            margin-bottom: 20px;
        }

        .no-report-message {
            font-size: 16px;
            color: #666;
            margin-bottom: 15px;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 8px;
        }

        .generate-report-btn {
            display: flex;
            align-items: center;
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            color: white;
            padding: 15px;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(79, 172, 254, 0.2);
        }

        .generate-report-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(79, 172, 254, 0.3);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="alert-icon"></div>
            <h1>股票异动预警详情</h1>
        </div>

        <div class="content">
            <!-- 错误信息显示 -->
            <div th:if="${errorMessage}" class="error-message" th:text="${errorMessage}">获取数据失败，请稍后重试</div>

            <div class="stock-info">
                <div class="stock-code" th:text="${alertDetail.stockCode}">--</div>
                <div class="stock-name" th:text="${alertDetail.stockName}">--</div>
            </div>

            <div class="info-grid">
                <div class="info-item">
                    <div class="info-label">当前价格</div>
                    <div class="info-value" th:text="${alertDetail.currentPrice}">--</div>
                </div>
                <div class="info-item">
                    <div class="info-label">涨跌幅</div>
                    <div class="info-value"
                         th:classappend="${#strings.contains(alertDetail.changeRatio, '-') ? 'price-down' : 'price-up'}"
                         th:text="${alertDetail.changeRatio}">--</div>
                </div>
                <div class="info-item">
                    <div class="info-label">触发阈值</div>
                    <div class="info-value" th:text="${alertDetail.triggerThreshold}">--</div>
                </div>
                <div class="info-item">
                    <div class="info-label">预警类型</div>
                    <div class="info-value" th:text="${alertDetail.abnormalType}">--</div>
                </div>
            </div>

            <div class="analysis-report">
                <!-- 有报告URL的情况 -->
                <div th:if="${alertDetail?.abnormalReportAttachmentUrl != null}">
                    <a th:href="@{${alertDetail.abnormalReportAttachmentUrl}}"
                       target="_blank"
                       class="report-btn">
                        <div class="report-icon">📊</div>
                        <div class="report-text">查看分析报告</div>
                        <div class="report-arrow">→</div>
                    </a>
                </div>

                <!-- 没有报告URL的情况 -->
                <div th:unless="${alertDetail.abnormalReportAttachmentUrl}" class="no-report">
                    <div class="no-report-message">暂无分析报告</div>
                    <div class="generate-report-btn" onclick="generateReport()">
                        <div class="report-icon">🔄</div>
                        <div class="report-text">生成分析报告</div>
                        <div class="report-arrow">→</div>
                    </div>
                </div>
            </div>

            <div class="alert-time">
                <div class="alert-time-label">预警时间</div>
                <div class="alert-time-value"
                     th:text="${alertDetail.triggerTime}">--</div>
            </div>

            <div class="risk-warning">
                请注意风险，理性投资！
            </div>
        </div>
    </div>

    <script th:inline="javascript">
        // 获取URL参数
        function getQueryParam(name) {
            const url = new URL(window.location.href);
            return url.searchParams.get(name);
        }

        // 页面加载完成后的处理
        document.addEventListener('DOMContentLoaded', function() {
            console.log('股票预警详情页面已加载');

            const stockCode = getQueryParam('stockCode');
            const recordId = getQueryParam('recordId');

            if (stockCode && recordId) {
                console.log('股票代码:', stockCode, '记录ID:', recordId);
            }
        });


        function generateReport() {
            alert('功能正在孵化中🐣，敬请期待 ~' );
        }

    </script>
</body>
</html>
